Skip to content

Fixes #38303: preserve BSON string column types in MongoDB/NoSQL ingestion - #38316

Merged
akashverma0786 merged 6 commits into
open-metadata:mainfrom
Kefia-02:fix/mongodb-preserve-native-string-column-38303-20261120
Nov 24, 2026
Merged

akashverma0786 merged 6 commits into
open-metadata:mainfrom
Kefia-02:fix/mongodb-preserve-native-string-column-38303-20261120

Conversation

@Kefia-02

@Kefia-02 Kefia-02 commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Problem

MongoDB view field CODIGO holds the BSON string "01051", but OpenMetadata 2.0.5 registers it as INT. The reporter verified 8,137 BSON string records. Numeric-looking codes lose their semantic leading-zero type in metadata, even though sample data still shows the original string.

The generic dataframe parser intentionally calls ast.literal_eval(str(value)) to infer types from CSV/datalake text. CommonNoSQLSource reused it for already-typed BSON values, so string values were incorrectly interpreted as integers or dates.

Fix

  • Introduce NoSQLDataFrameColumnParser, a small specialization used only by CommonNoSQLSource.
  • When sampled non-null values in a NoSQL object column are all native strings, preserve DataType.STRING instead of inferring the type again from the string contents.
  • Preserve the existing generic behavior for native numeric values, arrays, nested objects, and datalake/CSV inputs. No changes to the global inference logic.

Fixes #38303. Related investigation: #32075.

Tests

Added test_common_nosql_native_string_types.py covering:

  • Leading-zero MongoDB-like string codes alongside true integer counts.
  • Numeric-looking, date-looking and boolean-looking native strings.
  • Nested documents, lists and numeric types remaining distinct.
  • Existing generic datalake string-to-integer inference remaining unchanged.

The repository regression file test_common_nosql_native_string_types.py passed (4/4) using the source tree from 84ba1ec. The original MongoDB view integration scenario and upstream CI still await verification.

Prepared with AI assistance.

RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge; no actionable defects were found.

Summary

Adds NoSQLDataFrameColumnParser so sampled NoSQL columns containing only native strings stay STRING.

  • NoSQL columns keep string values as strings during type inference.

Reviews (7) · Last reviewed commit: "Merge branch 'main' into fix/mongodb-pre..." · Reviewed by Greptile


Summary by Gitar

  • MongoDB views:
    • Ingests MongoDB views as TableType.View via query_view_names_and_types
    • Excludes views from regular collection listing with a type filter in _list_collections
  • Tests:
    • Adds integration test test_views_are_ingested_as_views and a zip_code string column fixture

This will update automatically on new commits.

@Kefia-02
Kefia-02 requested a review from a team as a code owner November 20, 2026 14:30
@github-actions

Copy link
Copy Markdown
Contributor

❌ PR checklist incomplete

This PR cannot be merged until the following are addressed on its linked issue:

The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically.

Maintainers can bypass this check by adding the skip-pr-checks label.

@akashverma0786 akashverma0786 added the safe to test Add this label to run secure Github workflows on PRs label Nov 20, 2026
akashverma0786 and others added 3 commits November 23, 2026 12:59
… View

- Fix ruff format (py-checkstyle failure)
- Use "True"/"False" so the boolean case exercises the fix
- Move test to tests/unit/topology/database; drop redundant datalake test
- Add type hints to NoSQLDataFrameColumnParser.fetch_col_types
- Report MongoDB views as TableType.View via query_view_names_and_types
- Mongo integration test: numeric-looking string field and view type
- Replace the f-string debug log with %-style args (G004 check)
- Prune the obsolete G004 baseline entry for the removed log line
@gitar-bot

gitar-bot Bot commented Nov 24, 2026

Copy link
Copy Markdown
Code Review ✅ Approved 🟡 Medium risk

Preserving native NoSQL strings and classifying MongoDB views changes ingested metadata, so incorrect sampling or listing could misstate column and table types.

Preserves BSON string column types during MongoDB/NoSQL metadata ingestion by adding a NoSQL-specific column parser that keeps all-string columns as STRING instead of re-inferring integers or dates from their contents, and ingests MongoDB views as View tables. No issues found.

Verification

Rules No rules evaluated

Functional validation Not enabled

Set up

Auto-approval Not enabled

Set up

For more verification details, comment gitar display:verbose.

Options

Display: compact → Showing compact verification results.

Comment with these commands to change the behavior for this request:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source

@akashverma0786
akashverma0786 merged commit bb072b5 into open-metadata:main Nov 24, 2026
48 of 51 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

safe to test Add this label to run secure Github workflows on PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MongoDB string field incorrectly inferred as INT during metadata ingestion

3 participants